"""
udp查询客户端, 发送请求,展现请求结果
"""

from socket import *

class WordCilent:
	def __init__(self):
		self.__sockfd = socket(AF_INET, SOCK_DGRAM)
		self.__SERVERIP = ("127.0.0.1", 58693)

	def start(self):
		"""
			开启查询功能
		"""
		while True:
			data = input("查询单词: ")
			if not data:
				break
			self.__sockfd.sendto(data.encode(), self.__SERVERIP) # 发送

			date, addr = self.__sockfd.recvfrom(1024) # 接收
			print(f"结果: {date.decode()}")
		self.__sockfd.close()



op = WordCilent()
op.start()